/**
* Copyright (c) By zengqh.
*
* This program is just for fun or demo, in the hope that it  
* will be useful, you can redistribute it and/or modify freely.
*
* Time: 2013/03/03
* File: IndexBuffer.h
* Blog: http://www.cnblogs.com/zengqh/
**/

#pragma once

#include "RenderObject.h"

namespace HY
{
class IndexBuffer : public RenderObject
{
public:
	enum 
	{
		UInt   = 0,	/** Unsigned int (may not be supported by each API) */
		UShort = 1,	/** Unsigned short (default) */
	};

	/** Maximum vertex index which can be used if UShort is used as index buffer type */
	static const uint32 MaxVertexIndexUShort = 65535;

public:
	virtual ~IndexBuffer()
	{
		
	}

	uint32 getNumOfElements() const
	{
		return elems_;
	}

	uint32 getSize() const
	{
		return size_;
	}

	uint32 getUsage() const
	{
		return usage_;
	}

	uint32 getElementType() const
	{
		return elem_type_;
	}

	void setElementType(uint32 elem_type)
	{
		elem_type_ = elem_type;
	}

	virtual void bind() = 0;
	virtual void unbind() = 0;

	virtual bool create(uint32 elems, uint32 usage, uint32 type) = 0;

	virtual void* lock(uint32 flags) = 0;

	virtual bool unlock() = 0;

protected:
	IndexBuffer(uint32 elem_type)
		: RenderObject(TypeIndexBuffer)
		, elem_type_(elem_type)
	{

	}

protected:
	uint32	elem_type_;
	uint32	elems_;
	uint32	size_;
	uint32	usage_;
};
}